const app = require('express')()
const http = require('http').Server(app)
const io = require('socket.io')(http)

app.get('/', function(req, res) {
  res.sendFile(__dirname + '/views/index.html')
})

// io.on('connection', function(socket) {
//   console.log('a user is connected')
//   socket.on('disconnect', function() {
//     console.log('user is disconnected')
//   })
// })

io.on('connection', function(socket) {
  socket.on('chat message', function(msg) {
    io.emit('chat message', msg)
  })
})


http.listen(3000, function() {
  console.log('listen on 3000')
})